Imports MyClasses
Imports System.Data
Imports System.Data.SqlClient
Public Class DRoles

    Public Shared Function GetRoles() As DataTable
        Dim strSql As String = ""
        Try
            strSql = "SELECT 0 as RoleId,'' as RoleName FROM mRoles UNION " & _
                     "SELECT RoleID as RoleId,Name as RoleName FROM mRoles where RoleID <> 1"

            Return DbHelper.ExecuteDataTable(strSql)
        Catch ex As Exception
            DGeneral.ErrorHandler(ex.Message, "DAL", "DRoles", "GetRoles", strSql)
            Return Nothing
        End Try
    End Function

    Public Shared Function GetEmpRole(ByVal EmpId As Integer) As DataTable
        Dim strSql As String = ""
        Try
            strSql = "SELECT e.SeqEmpID as ID, FName +' '+ MName +' '+ LName AS 'Employee',u.UserId AS 'UserName',r.Name AS 'Role' " & _
                     "FROM mEmp e, mPerson p, mpUser u, mRoles r where p.PersonId=e.PersonId AND p.PersonId=u.PersonId AND " & _
                     "u.EmpId=e.EmpId AND r.RoleID=u.RoleID AND e.EmpID=" & EmpId

            Return DbHelper.ExecuteDataTable(strSql)
        Catch ex As Exception
            DGeneral.ErrorHandler(ex.Message, "DAL", "DRoles", "GetRoles", strSql)
            Return Nothing
        End Try
    End Function
End Class
